﻿using System;
using System.Collections.Generic;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;

namespace FaceProcessingWrapper.Test
{
    [TestFixture]
    public class FaceRecoWrapperTest
    {
        [Test]
        public void Test()
        {
            //
            // TODO: Add test logic here
            //
            var comparer = FaceRecoWrapper.FromModel(@"model.txt",
                                                     @"haarcascade_frontalface_alt2.xml");

            var pic1 = OpenCvSharp.IplImage.FromFile("1.bmp");
            var pic2 = OpenCvSharp.IplImage.FromFile("2.bmp");


            var fp1 = new FaceSpecification();
            var suc1 = comparer.CalcFeature(pic1, fp1);

            var fp2 = new FaceSpecification();
            var suc2 = comparer.CalcFeature(pic2, fp2);

            var similarIpl = comparer.CmpFace(fp1, fp2);

            var pic1Bmp = pic1.ToBitmap();
            suc1 = comparer.CalcFeature(OpenCvSharp.IplImage.FromBitmap(pic1Bmp), fp1);

            var pic2Bmp = pic2.ToBitmap();
            suc2 = comparer.CalcFeature(OpenCvSharp.IplImage.FromBitmap(pic2Bmp), fp2);

            var similarBmp = comparer.CmpFace(fp1, fp2);

            Assert.IsTrue(similarIpl == similarBmp);
        }
    }
}
